// 汇报类型
export const reportTypeOptions = [{
  value: 1,
  label: '日报'
}, {
  value: 2,
  label: '周报'
}, {
  value: 3,
  label: '月报'
}, {
  value: 4,
  label: '年报'
}]
// 数据汇总字段类型
export const summaryDataFieldOptions = [{
  label: '销售额',
  value: 1
}, {
  label: '退货率',
  value: 2
}, {
  label: '推广费',
  value: 3
}]
// 店铺名称
export const storeNameOptions = [{
  value: 1,
  label: '青蔷薇'
}, {
  value: 2,
  label: '一雯白'
}, {
  value: 3,
  label: 'DREAM SEVEN77'
}, {
  value: 4,
  label: '财哥不熬夜'
}, {
  value: 5,
  label: '辣妹曦曦子'
}, {
  value: 6,
  label: '佩佩店'
}, {
  value: 7,
  label: '生生店'
}, {
  value: 8,
  label: '罗哥'
}]
// 店铺类型
export const storeTypeOptions = [{
  value: 1,
  label: '淘系'
}, {
  value: 2,
  label: '抖店'
}]
// 时间周期
export const timeUnitOption = [{
  value: 'WEEK',
  label: '周'
}, {
  value: 'MONTH',
  label: '月'
}, {
  value: 'YEAR',
  label: '年'
}]
// 本周、上周 or 下周
export const periodsOption = [{
  value: 'LAST',
  label: '上周'
}, {
  value: 'THIS',
  label: '本周'
}, {
  value: 'NEXT',
  label: '下周'
}]
// 店铺字段类型
export const storeDataFieldOption = [{
  value: 1,
  label: '销售额'
}, {
  value: 2,
  label: '广告费占比'
}, {
  value: 3,
  label: '店铺支付转化率'
}, {
  value: 4,
  label: '退货率'
}, {
  value: 5,
  label: '发货时长'
}, {
  value: 6,
  label: '抖音销售额'
}, {
  value: 7,
  label: '仓库库存总数'
}]
// 问题板块分类
export const issueTypeOptions = [{
  value: 1,
  label: '主要问题'
}, {
  value: 2,
  label: '重点工作'
}]
// 周期
export const wekkOptions = [{
  label: '第一周',
  value: 1
}, {
  label: '第二周',
  value: 2
}, {
  label: '第三周',
  value: 3
}, {
  label: '第四周',
  value: 4
}, {
  label: '第五周',
  value: 5
}]
// 新媒体数据类型
export const mediaDataTypeOption = [{
  label: '签约',
  value: 1
}, {
  label: '孵化',
  value: 2
}, {
  label: '汇总',
  value: 3
}]
// 新媒体数据字段
export const mediaDataFieldOption = [{
  label: '短视频转化金额',
  value: 1
}, {
  label: '直播转化金额',
  value: 2
}, {
  label: '涨粉数量',
  value: 3
}, {
  label: '推广费用',
  value: 4
}, {
  label: '红人签约',
  value: 5
}, {
  label: '邀约人数',
  value: 11
}, {
  label: '面试人数',
  value: 12
}, {
  label: '签约人数',
  value: 13
}, {
  label: '自定义',
  value: 91
}]
// 新媒体内容分类
export const mediaDocumentTypeOption = [{
  label: '新媒体-重点孵化达人',
  value: 1
}, {
  label: '新媒体-新签达人',
  value: 2
}, {
  label: '新媒体-近期热门穿搭',
  value: 3
}]

// 汇报基本字段
const baseFields = [
  {
    name: '汇报名称',
    field: 'reportName',
    formType: 'text',
    placeholder: '请输入',
    percent: '20%',
    setting: []
  },
  // {
  //   name: '汇报类型',
  //   field: 'reportType',
  //   formType: 'radio',
  //   disabled: true,
  //   setting: reportTypeOptions
  // },
  {
    name: '月份',
    field: 'month',
    formType: 'month',
    percent: '20%',
    setting: []
  },
  {
    name: '周期',
    field: 'targetWeek',
    formType: 'select',
    percent: '20%',
    setting: wekkOptions
  },
  {
    name: '汇报材料',
    field: 'files',
    formType: 'file',
    percent: '20%',
    setting: []
  },
  {
    name: '汇报对象',
    field: 'ownerUserIds',
    formType: 'employee',
    radio: false,
    percent: '20%',
    setting: []
  },
  {
    name: '汇报内容',
    field: 'reportContent',
    formType: 'editor',
    percent: '100%',
    setting: []
  }
  // {
  //   name: '抄送对象',
  //   field: 'copyUserIds',
  //   formType: 'user',
  //   props: { label: 'employeeName', value: 'employeeId' },
  //   radio: false,
  //   setting: []
  // }
]
const weekInMonth = getWeekInMonth(new Date())
const baseForm = {
  month: new Date().getFullYear() + '-' + (new Date().getMonth() + 1),
  targetYear: new Date().getFullYear(),
  targetMonth: new Date().getMonth() + 1,
  targetWeek: weekInMonth < 6 ? (weekInMonth - 1 > 0 ? weekInMonth - 1 : weekInMonth) : 5,
  reportType: 2,
  reportContent: '',
  files: []
}
const baseRules = {
  reportName: [
    { required: true, message: '请输入汇报名称', trigger: ['blur', 'change'] }
  ],
  month: [
    { required: true, message: '请选择月份', trigger: ['blur', 'change'] }
  ],
  targetWeek: [
    { required: true, message: '请选择周期', trigger: ['blur', 'change'] }
  ]
  // reportContent: [
  //   { required: true, message: '请输入汇报内容', trigger: ['blur', 'change'] }
  // ],
  // ownerUserIds: [
  //   { required: true, message: '请选择汇报对象', trigger: ['blur', 'change'] }
  // ]
}
export const baseModel = {
  field: baseFields,
  rule: baseRules,
  form: baseForm
}


// 品牌数据字段
const brandFields = [
  {
    label: '店铺名',
    field: 'storeType',
    formType: 'select',
    percent: '20%',
    setting: storeNameOptions
  },
  // {
  //   label: '目标周期',
  //   field: 'period',
  //   formType: 'select',
  //   disabled: true,
  //   percent: '20%',
  //   setting: timeUnitOption,
  //   rules: [
  //     { required: true, message: '请选择周期', trigger: ['blur', 'change'] }
  //   ]
  // },
  {
    label: '销售额',
    field: 'sale',
    formType: 'number',
    percent: '20%',
    setting: []
  },
  {
    label: '退货率',
    field: 'refundRate',
    formType: 'percent',
    percent: '20%',
    setting: []
  },
  {
    label: '推广费',
    field: 'promotionExpenses',
    formType: 'number',
    percent: '20%',
    setting: []
  }
]
const brandForm = {
  storeType: 1,
  period: 'WEEK',
  sale: '',
  refundRate: '',
  promotionExpenses: ''
}
const brandRules = {
  storeType: [
    { required: true, message: '请选择店铺名', trigger: ['blur', 'change'] }
  ],
  period: [
    { required: true, message: '请选择目标周期', trigger: ['blur', 'change'] }
  ],
  sale: [
    { required: true, message: '请输入销售额', trigger: ['blur', 'change'] }
  ],
  refundRate: [
    { required: true, message: '请输入退货率', trigger: ['blur', 'change'] }
  ],
  promotionExpenses: [
    { required: true, message: '请输入推广费', trigger: ['blur', 'change'] }
  ]
}
export const brandModel = {
  field: brandFields,
  form: brandForm,
  rule: brandRules
}

// 汇总数据字段
const summaryFields = [
  {
    name: '数据字段',
    field: 'dataField',
    formType: 'select',
    placeholder: '选择',
    percent: '16%',
    disabled: true,
    setting: summaryDataFieldOptions
  },
  {
    name: '上周目标值',
    field: 'target',
    formType: 'number',
    placeholder: '请输入',
    percent: '16%',
    setting: []
  },
  {
    name: '上周实际值',
    field: 'actual',
    formType: 'number',
    placeholder: '请输入',
    percent: '16%',
    setting: []
  },
  {
    name: '截止上周',
    field: 'complete',
    formType: 'number',
    placeholder: '请输入',
    percent: '16%',
    setting: []
  },
  {
    name: '截止目前',
    field: 'completeNow',
    placeholder: '请输入',
    formType: 'number',
    percent: '16%',
    setting: []
  },
  {
    name: '完成进度',
    field: 'completeProgress',
    placeholder: '请输入',
    formType: 'percent',
    percent: '20%',
    setting: []
  }
]
const summaryForm = {
  platform: 1,
  period: 'WEEK',
  dataField: 1,
  target: '',
  actual: '',
  complete: '',
  completeNow: '',
  completeProgress: ''
}
const summaryRules = {
  target: [
    { required: true, message: '请输入目标值', trigger: ['blur', 'change'] }
  ],
  actual: [
    { required: true, message: '请输入实际值', trigger: ['blur', 'change'] }
  ]
}
export const summaryModel = {
  field: summaryFields,
  form: summaryForm,
  rule: summaryRules
}

// 外部环境相关数据
const environmentFields = [
  {
    name: '大盘趋势',
    field: 'marketTrend',
    formType: 'textarea',
    placeholder: '请输入',
    setting: []
  },
  {
    name: '抖音板块',
    field: 'tiktokPlate',
    formType: 'textarea',
    placeholder: '请输入',
    setting: []
  },
  {
    name: '直播板块',
    field: 'livePlate',
    formType: 'textarea',
    placeholder: '请输入',
    setting: []
  }
]
const environmentForm = {
  marketTrend: '',
  tiktokPlate: '',
  livePlate: ''
}
const environmentRules = {
  marketTrend: [
    { required: true, message: '请输入大盘趋势', trigger: ['blur', 'change'] }
  ],
  tiktokPlate: [
    { required: true, message: '请输入抖音板块', trigger: ['blur', 'change'] }
  ],
  livePlate: [
    { required: true, message: '请输入直播板块', trigger: ['blur', 'change'] }
  ]

}
export const environmentModel = {
  field: environmentFields,
  form: environmentForm,
  rule: environmentRules
}

// 店铺相关数据
const storeFields = periods => {
  let fields = [
    {
      label: '店铺类型',
      field: 'storeType',
      formType: 'select',
      disabled: true,
      setting: storeTypeOptions
    },
    {
      label: '数据分类',
      field: 'dataField',
      formType: 'select',
      placeholder: '请选择',
      setting: storeDataFieldOption
    },
    {
      label: (periods == 'LAST' ? '上周' : '本周') + '目标值',
      field: 'target',
      formType: 'number',
      placeholder: '请输入',
      setting: []
    }]
  if (periods == 'LAST') {
    fields = fields.concat([{
      label: (periods == 'LAST' ? '上周' : '本周') + '实际值',
      field: 'actual',
      formType: 'number',
      placeholder: '请输入',
      setting: []
    },
    {
      label: '周完成进度',
      field: 'completedWeek',
      formType: 'percent',
      placeholder: '请输入',
      setting: []
    },
    {
      label: '月完成进度',
      field: 'completedMonth',
      formType: 'percent',
      placeholder: '请输入',
      setting: []
    }])
  }
  fields = fields.concat([{
    label: periods == 'LAST' ? '上周达成分析' : '本周目标分解',
    field: 'performance',
    formType: 'textarea',
    minRows: 1,
    resize: 'both',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '补充说明',
    field: 'instruction',
    formType: 'textarea',
    minRows: 1,
    resize: 'both',
    placeholder: '请输入',
    setting: []
  }])
  return fields
}
const storeForm = (periods, storeType) => {
  return {
    period: periods,
    storeType: storeType,
    dataField: '',
    target: '',
    actual: '',
    completedWeek: '',
    completedMonth: '',
    performance: '',
    instruction: ''
  }
}
const storeRules = {
  storeType: [
    { required: true, message: '请选择店铺类型', trigger: ['blur', 'change'] }
  ],
  dataField: [
    { required: true, message: '请选择数据分类', trigger: ['blur', 'change'] }
  ],
  target: [
    { required: true, message: '请输入目标值', trigger: ['blur', 'change'] }
  ],
  actual: [
    { required: true, message: '请输入实际值', trigger: ['blur', 'change'] }
  ]
  // completed: [
  //   { required: true, message: '请输入完成进度', trigger: ['blur', 'change'] }
  // ],
  // performance: [
  //   { required: true, message: '请输入达成分析/目标分解', trigger: ['blur', 'change'] }
  // ]
}
export const storeModel = {
  field: storeFields,
  form: storeForm,
  rule: storeRules
}

// 直播相关数据
const liveFields = [
  {
    label: '直播时间',
    field: 'liveTime',
    formType: 'date',
    placeholder: '请选择',
    setting: [],
    width: 200
  },
  {
    label: '直播时长(分)',
    field: 'liveDuration',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '直播数据',
    field: 'liveData',
    formType: 'image',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '千次观看',
    field: 'watchThousand',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: 'GMV',
    field: 'liveGmv',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: 'UV',
    field: 'liveUv',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '场观',
    field: 'watchInside',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '转化率',
    field: 'conversionRatio',
    formType: 'percent',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '停留时长(秒)',
    field: 'talkTime',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: 'GPM',
    field: 'liveGpm',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '平均在线人数',
    field: 'onlineAverage',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '在线人数峰值',
    field: 'onlinePeak',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '老粉成交占比',
    field: 'fansTradeRatio',
    formType: 'percent',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '新增粉丝数',
    field: 'increaseFans',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '新增粉丝团',
    field: 'increaseFansClub',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  }
]
const liveForm = {
  liveTime: '',
  liveDuration: '',
  liveData: '',
  watchThousand: '',
  liveGmv: '',
  liveUv: '',
  watchInside: '',
  conversionRatio: '',
  talkTime: '',
  liveGpm: '',
  onlineAverage: '',
  onlinePeak: '',
  fansTradeRatio: '',
  increaseFans: '',
  increaseFansClub: ''
}
const liveRules = {
  liveTime: [
    { required: true, message: '请选择直播时间', trigger: ['blur', 'change'] }
  ],
  liveDuration: [
    { required: true, message: '请输入直播时长', trigger: ['blur', 'change'] }
  ],
  liveData: [
    { required: true, message: '请上传直播数据', trigger: ['blur', 'change'] }
  ],
  watchThousand: [
    { required: true, message: '请输入千次观看', trigger: ['blur', 'change'] }
  ],
  liveGmv: [
    { required: true, message: '请输入gmv', trigger: ['blur', 'change'] }
  ],
  liveUv: [
    { required: true, message: '请输入uv', trigger: ['blur', 'change'] }
  ],
  watchInside: [
    { required: true, message: '请输入场观', trigger: ['blur', 'change'] }
  ],
  conversionRatio: [
    { required: true, message: '请输入转化率', trigger: ['blur', 'change'] }
  ],
  talkTime: [
    { required: true, message: '请输入停留时长', trigger: ['blur', 'change'] }
  ],
  liveGpm: [
    { required: true, message: '请输入gpm', trigger: ['blur', 'change'] }
  ],
  onlineAverage: [
    { required: true, message: '请输入平均在线人数', trigger: ['blur', 'change'] }
  ],
  onlinePeak: [
    { required: true, message: '请输入在线人数峰值', trigger: ['blur', 'change'] }
  ],
  fansTradeRatio: [
    { required: true, message: '请输入老粉成交占比', trigger: ['blur', 'change'] }
  ],
  increaseFans: [
    { required: true, message: '请输入新增粉丝数', trigger: ['blur', 'change'] }
  ],
  increaseFansClub: [
    { required: true, message: '请输入新增粉丝团个数', trigger: ['blur', 'change'] }
  ]
}
export const liveModel = {
  field: liveFields,
  form: liveForm,
  rule: liveRules
}

// 问题及解决方案相关数据
const issueFields = [
  // {
  //   label: '板块分类',
  //   field: 'type',
  //   formType: 'select',
  //   setting: issueTypeOptions
  // },
  {
    label: '标题',
    field: 'title',
    formType: 'textarea',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '内容',
    field: 'content',
    formType: 'textarea',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '解决方案',
    field: 'solution',
    formType: 'textarea',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '备注',
    field: 'remark',
    formType: 'textarea',
    placeholder: '请输入',
    setting: []
  }
]
const issueForm = {
  type: '',
  title: '',
  content: '',
  solution: '',
  remark: ''
}
const issueRules = {
  title: [
    { required: true, message: '请输入标题', trigger: ['blur', 'change'] }
  ],
  content: [
    { required: true, message: '请输入内容', trigger: ['blur', 'change'] }
  ]
}
export const issueModel = {
  field: issueFields,
  form: issueForm,
  rule: issueRules
}

// 新媒体数据
const mediaFields = (dataType) => {
  let fields = [{
    label: '数据字段',
    field: 'dataField',
    formType: 'select',
    placeholder: '请选择',
    width: 200,
    setting: mediaDataFieldOption
  }]
  if (dataType == 2) {
    fields.push({
      label: '红人昵称',
      field: 'favouriteNickname',
      formType: 'text',
      placeholder: '请输入',
      setting: []
    })
  }
  fields.push({
    label: (dataType == 3 ? '本周' : '上周') + '目标值',
    field: 'target',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  })
  if (dataType != 3) {
    fields = fields.concat([{
      label: '上周实际值',
      field: 'actual',
      formType: 'number',
      placeholder: '请输入',
      setting: []
    },
    {
      label: '周完成进度',
      field: 'completedWeek',
      formType: 'percent',
      placeholder: '请输入',
      setting: []
    },
    {
      label: '月完成进度',
      field: 'completedMonth',
      formType: 'percent',
      placeholder: '请输入',
      setting: []
    }])
  }
  fields = fields.concat([
    {
      label: dataType == 3 ? '本周目标分解' : '上周达成分析',
      field: 'performance',
      formType: 'textarea',
      placeholder: '请输入',
      minRows: 1,
      resize: 'both',
      setting: []
    },
    {
      label: '补充说明',
      field: 'instruction',
      formType: 'textarea',
      placeholder: '请输入',
      minRows: 1,
      resize: 'both',
      setting: []
    }
  ])
  return fields
}
const mediaForm = {
  period: 'THIS',
  dataType: '',
  dataField: '',
  favouriteNickname: '',
  target: '',
  actual: '',
  completedWeek: '',
  completedMonth: '',
  instruction: '',
  performance: ''
}
const mediaRules = {
  storeType: [
    { required: true, message: '请选择店铺类型', trigger: ['blur', 'change'] }
  ],
  dataField: [
    { required: true, message: '请选择数据分类', trigger: ['blur', 'change'] }
  ]
}
// 孵化数据
export const incubationMediaCommonFields = [
  {
    label: '目标值',
    field: 'target',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '实际值',
    field: 'actual',
    formType: 'number',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '完成率',
    field: 'completedWeek',
    formType: 'percent',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '补充说明',
    field: 'instruction',
    formType: 'textarea',
    minRows: 1,
    resize: 'both',
    placeholder: '请输入',
    setting: []
  }
]
const incubationMediaFields = [
  {
    label: '红人昵称',
    field: 'favouriteNickname',
    formType: 'text',
    placeholder: '请输入',
    setting: []
  },
  {
    label: '短视频转化金额',
    setting: [],
    formIndex: 0,
    children: incubationMediaCommonFields
  },
  {
    label: '直播转化金额',
    setting: [],
    formIndex: 1,
    children: incubationMediaCommonFields
  },
  {
    label: '涨粉数量',
    setting: [],
    formIndex: 2,
    children: incubationMediaCommonFields
  },
  {
    label: '推广费',
    setting: [],
    formIndex: 3,
    children: incubationMediaCommonFields
  }
]
const incubationMediaRules = {
  storeType: [
    { required: true, message: '请选择店铺类型', trigger: ['blur', 'change'] }
  ],
  dataField: [
    { required: true, message: '请选择数据分类', trigger: ['blur', 'change'] }
  ],
  favouriteNickname: [
    { required: true, message: '请输入红人昵称', trigger: ['blur', 'change'] }
  ]
}
export const mediaModel = {
  field: mediaFields,
  form: mediaForm,
  rule: mediaRules,
  incubationMediaFields: incubationMediaFields,
  incubationMediaRules: incubationMediaRules
}

// 新媒体文档内容数据
const documentFields = [
  {
    name: '标题',
    field: 'title',
    formType: 'text',
    placeholder: '请输入',
    percent: '100%',
    setting: []
  },
  {
    name: '内容',
    field: 'content',
    formType: 'editor',
    placeholder: '请输入',
    percent: '100%',
    setting: []
  },
  {
    name: '备注',
    field: 'remark',
    formType: 'text',
    placeholder: '请输入',
    percent: '100%',
    setting: []
  }
]
const documentForm = {
  type: '',
  title: '',
  content: '',
  remark: ''
}
const documentRules = {
  title: [
    { required: true, message: '请输入标题', trigger: ['blur', 'change'] }
  ],
  content: [
    { required: true, message: '请输入内容', trigger: ['blur', 'change'] }
  ]
}
export const documentModel = {
  field: documentFields,
  form: documentForm,
  rule: documentRules
}

// 根据日期判断是月的第几周
export function getWeekInMonth(t) {
  if (t == undefined || t == '' || t == null) {
    t = new Date()
  } else {
    var _t = new Date()
    _t.setYear(t.getFullYear())
    _t.setMonth(t.getMonth())
    _t.setDate(t.getDate())

    var date = _t.getDate() // 给定的日期是几号

    _t.setDate(1)
    var d = _t.getDay() // 1. 得到当前的1号是星期几。
    var fisrtWeekend = d
    if (d == 0) {
      fisrtWeekend = 1
      // 1号就是星期天
    } else {
      fisrtWeekend = 7 - d + 1 // 第一周的周未是几号
    }
    if (date <= fisrtWeekend) {
      return 1
    } else {
      return 1 + Math.ceil((date - fisrtWeekend) / 7)
    }
  }
}
